
/*
 * 
 * Job that checks if the URL hasn't been scraped yet 
 */

package jobs;

import jobs.BaseJob;
import core.Crawler;
import database.SqlManager;

import java.net.URI;

public class ValidatePageJob extends BaseJob 
{
	private URI mUrl;
		
	public ValidatePageJob(URI url) 
	{
		mUrl = url;
		
		if ( mUrl.getScheme() == null )
		{
			mUrl = URI.create("http://" + url.toString());
		}
	}

	@Override
	public boolean run() 
	{
		if ( !SqlManager.getInstance().isLinkVisited( mUrl ) )
		{
			Crawler.getInstance().addAcceptedPageUrl( mUrl );
			return true;
		}
		
		return false;
	}

}
